<template>
      <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady" 
          style="height:500px" class='ag-theme-alpine'
          :defaultColDef="defaultColDef" :rowData="table.dataList" 
          :columnDefs="cfsValue" :localeText="localeTextData"/>
    <paginationCopys :total="total" show-total show-jumper 
        show-page-size @change="changePage"  @page-size-change="changeSize" 
        style="justify-content: center;margin-top: 10px;"  :page-size="pagination.pageSize"
        :current="pagination.page" />
</template>

<script lang="ts">
    
    import emitter from "@/hooks/useEventBus";
    import { localeText } from '@/api/aggridZw'
    import { onMounted,reactive, ref } from 'vue';
    import { assTable } from '@/utils/assemblyLevelTable';
    import { Message } from '@arco-design/web-vue';
    import { usePagination, useTable } from '@/hooks/table';
    export default {
       name:'untreated',
       components: {  },
       props:{
            searchData:{
                type:Object,
                default:() => {}
            }
       },
       setup(props,{emit}){
            const table = useTable();
            emitter.on("refresh-untreated", () => {
                pagination.page = 1;
                doRefresh();
            });
            const doRefresh = () => {};
            const pagination = usePagination(doRefresh);
            //表格方面
            const gridOption = ref();
            const gridReady = (params:any) => {
                gridOption.value = params.api; 
                //调整表格自适应大小
            }
            const defaultColDef = {
                sortable: true,
                resizable: true,
                filter: true,
                width: 150
            };
            let cfsValue:any = [
                {
                    headerName: "序号",
                    field: "serialNo",
                },
                {
                    headerName: "流转卡号",
                    field: "circulatCard",
                },
                {
                    headerName: "开单日期",
                    field: "billDate",
                },
                {
                    headerName: "设备单号",
                    field: "serialNo",
                },
                {
                    headerName: "客户名称",
                    field: "serialNo",
                },
                {
                    headerName: "计划单号",
                    field: "serialNo",
                },
                {
                    headerName: "合约号",
                    field: "serialNo",
                },
                {
                    headerName: "加工类型",
                    field: "serialNo",
                },
                {
                    headerName: "作业类型",
                    field: "serialNo",
                },
                {
                    headerName: "等待工序",
                    field: "serialNo",
                },
                {
                    headerName: "客户订单号",
                    field: "serialNo",
                },
                {
                    headerName: "色号",
                    field: "serialNo",
                },
                {
                    headerName: "色称",
                    field: "serialNo",
                },
                {
                    headerName: "纱批",
                    field: "serialNo",
                },
            ];
            let a = [{
                showRowGroup: 'hide_def',
                "headerName": "",
                "checkboxSelection": true,
                "headerCheckboxSelection": true,
                "pinned": "left",
                "width": 50,
                resizable: false,
                filter: false,
                sortable: false,
                minWidth: 50,
                maxWidth: 50,
                lockPosition: "left",
            }]
            cfsValue = a.concat(cfsValue);
            const total = ref(10);
            const changePage = (val:any) => {
                pagination.page = val
                doRefresh();
            }
            const changeSize = (val:any) => {
                pagination.pageSize = val
                doRefresh();
            }

            const localeTextData :any = ref(localeText);
            emitter.on('export-untreated',() => { 
                let selectList = gridOption.value.getSelectedRows();
                // console.log(selectList);
                if (selectList.length === 0) {
                    Message.error('请勾选需要导出的数据')
                    return
                } else {
                    //导出数据
                    let nowRow = table.dataList.filter(function (o) {
                        return (gridOption.value.getSelectedRows().map((o: any) => { return o.id })).indexOf(o["id"]) !== -1;
                    })
                    assTable(cfsValue,nowRow,'车间退库信息(待处理)');
                }
            });
            return {
                pagination,
                table,
                localeTextData,
                changePage,
                changeSize,
                total,
                cfsValue,
                defaultColDef,
                gridReady,
            }
      
        },
   }
</script>

<style lang="less" scoped>

</style>